//
//  ViewController.m
//  UMCrashTest
//
//  Created by wangkai on 2018/10/25.
//  Copyright © 2018 wangkai. All rights reserved.
//

#import "ViewController.h"
#import <UMAPM/UMCrashConfigure.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    UILabel * titleLabel = [[UILabel alloc]init];
    titleLabel.text = @"需断开XCode调试模式下产生crash，才可统计到";
    titleLabel.frame = CGRectMake(20, 100, 500, 16);
    titleLabel.font = [UIFont systemFontOfSize:13];
    titleLabel.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1/1.0];
    [self.view addSubview:titleLabel];
    
    
    // Do any additional setup after loading the view, typically from a nib.
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:CGRectMake(100, 200, 200, 40)];
    [button setBackgroundColor:[UIColor colorWithRed:141/255.0 green:166/255.0 blue:196/255.0 alpha:1.0]];
    [button setTitle:@"点击产生OC层crash" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(ocClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button1 setFrame:CGRectMake(100, 300, 200, 40)];
    [button1 setBackgroundColor:[UIColor colorWithRed:141/255.0 green:166/255.0 blue:196/255.0 alpha:1.0]];
    [button1 setTitle:@"点击产生非OC层crash" forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(nativeClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button1];
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button2 setFrame:CGRectMake(100, 400, 200, 40)];
    [button2 setBackgroundColor:[UIColor colorWithRed:141/255.0 green:166/255.0 blue:196/255.0 alpha:1.0]];
    [button2 setTitle:@"产生回调" forState:UIControlStateNormal];
    [button2 addTarget:self action:@selector(callBackClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button2];
   
}
-(void)ocClick{
    
    NSMutableArray *array=[[NSMutableArray alloc]init];
    [array addObject:nil];
    
}

-(void)nativeClick{
    
    char *p = NULL;
    char a[30] = "string(1)";
    strcpy(p, a);
    
}

-(void)callBackClick{
    
    [UMCrashConfigure setCrashCBBlock:^NSString * _Nullable{
        NSLog(@"UMCB");
        return @"UMString";
    }];
    
}


@end
